<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>oop1(面向对象程序设计)</title>
</head>
<body>
<script type="text/javascript">
	//工厂模式
	/*function people(name, sex, age) {
		var obj = new Object();
		obj.name = name;
		obj.sex = sex;
		obj.age = age;
		obj.getName = function () {
			alert(obj.name)
		}
		return obj;
	}

	var p1 = people("jerry", "男", 24);

	p1.getName();
	*/


	//构造函数式
	function People(name, sex, age){
		this.name = name;
		this.sex = sex;
		this.age = age;
		this.getName = function () {
			alert(this.name);
		}
	}

	var p1 = new People("jerry", "男", 24);
	var p2 = new People("jzz", "女", 20);

	//p1.getName();
	//alert(p1.constructor == People);

	alert(p1 instanceof People);


</script>
</body>
</html>